﻿using System;
using System.Collections.Generic;
using System.Text;
using KingSite.SyncDB.Core.Entity;
using System.Collections;

namespace KingSite.SyncDB.Core.Repository {
    public class ColumnRepository : BaseProvider {

        public void InsertColumnEntity(ColumnEntity entity) {
            if (entity == null) throw new ArgumentNullException("entity");
            String stmtId = "ColumnEntity.Insert";
            SqlMapper.Insert(stmtId, entity);
        }

        public int GetColumnId(int tableId, string columnName) {
            Hashtable ht = new Hashtable();
            ht.Add("TableId", tableId);
            ht.Add("ColumnName", columnName);
            String stmtId = "ColumnEntity.Find";
            int id = SqlMapper.QueryForObject<int>(stmtId, ht);
            return id;
        }

        public void DeleteFromTableId(int tableId) {
            String stmtId = "ColumnEntity.DeleteFromTableId";
            SqlMapper.Delete(stmtId, tableId);
        }


        public void UpdateColumnEntity(ColumnEntity entity) {
            if (entity == null) throw new ArgumentNullException("entity");
            String stmtId = "ColumnEntity.Update";
            SqlMapper.Update(stmtId, entity);
        }
    }
}
